# money = 5000000
# name = input("请输入您的姓名：")
#
# def menu():
#     print(f'''{name}好，欢迎来到黑马银行ATM。请选择操作：
#                查询余额 [输入1]
#                存款    [输入2]
#                取款    [输入3]
#                退出    [输入4]
#     ''')
#
#
# def money_left():
#     print(f"您的余额{money}元")
#
# def set_money(x):
#     global money
#     money += x
#     print(f"{name}，您好，您存款{x}元成功！")
#     print(f"您的余额{money}元")
#
#
# def get_money(x):
#     global money
#     money -= x
#     print(f"{name}，您好，您取款{x}元成功！")
#     print(f"您的余额{money}元")
#
# while 1:
#     menu()
#     choice = int(input( "请输入您的选择："))
#     if choice == 1:
#         money_left()
#     if choice == 2:
#         x = int(input("输入您要存的钱数（元）"))
#         set_money(x)
#     if choice == 3:
#         x = int(input("输入您要取的钱数（元）"))
#         get_money(x)
#     if choice == 4:
#         break

money = 5000000
name = None

name = input("请输入您的姓名：")

def query(show_header):
    if show_header:
        print("-------查询余额---------")
    print(f"您的余额{money}元")

def saving(num):
    global money
    money += num
    print("--------存款----------")
    print(f"{name}，您好，您存款{num}元成功！")
    query(False)


def get_money(x):
    global money
    money -= x
    print("--------取款----------")
    print(f"{name}，您好，您取款{x}元成功！")
    query(False)

def main():
    print("--------菜单----------")
    print(f"{name}好，欢迎来到黑马银行ATM。请选择操作：")
    print("查询余额\t[输入1]")
    print("存款\t\t[输入2]")
    print("取款\t\t[输入3]")
    print("退出\t\t[输入4]")
    return input("请输入您的选择")

while 1:
    keyboard_input = main()
    if keyboard_input == '1':
        query(True)
        continue
    elif keyboard_input == '2':
        num = int(input("输入您要存的钱数（元）"))
        saving(num)
        continue
    elif keyboard_input == '3':
        num = int(input("输入您要取的钱数（元）"))
        get_money(num)
        continue
    else:
        print("程序退出了")
        break
